extends TextureRect

 #{
	#"id": "frostbite",
	#"buffer_name": "冻伤",
	#"descriptions": "冻伤会导致目标的体温急剧下降，造成持续的冷伤害 ",
	#"effect": "每回合造成%s点冰冻伤害",
	#"triggle": 0,
	#"params": [
		#3,
		#50
	#]
#}
@onready var name_label = $Popup/MarginContainer/VBoxContainer/NameLabel
@onready var cur_round_label = $Popup/MarginContainer/VBoxContainer/NameLabel/CurRoundLabel
@onready var desc_label = $Popup/MarginContainer/VBoxContainer/DescLabel
@onready var popup = $Popup

var id:String
var buffer_name:String
var descriptions:String
var effect:String
var triggle:int # 触发时机
var cur_round:int = 1:
	set(value):
		cur_round = value
		$Popup/MarginContainer/VBoxContainer/NameLabel/CurRoundLabel.text = "剩余: %s 回合" % cur_round
var max_round:int:
	set(value):
		max_round = value
var buffer:Buffer
func _ready() -> void:
	id = buffer.id
	var attributes = DataManager.data.buffers[id]
	buffer_name = attributes.buffer_name
	descriptions = attributes.descriptions
	triggle = attributes.triggle
	var params = buffer.params
	effect = attributes.effect % params.slice(1) #第一个值是回合数，不需要显示
	name_label.text = buffer_name
	desc_label.text = effect
	popup.position = global_position + Vector2(15,0)
	texture = load("res://assets/" + id + ".tres")

func _on_mouse_entered():
	popup.show()


func _on_mouse_exited():
	popup.hide()
